﻿@using SCMS.Resources
@model SCMS.UI.Models.GRNote
@{AjaxOptions ajaxOpts = new AjaxOptions
{
    UpdateTargetId = "ContentDiv",
    LoadingElementId = "loading",
    HttpMethod = "Post",
    Url = Url.Action("SaveGRN"),
    OnBegin = "ValidateGRN",
    OnSuccess = "usermsg('" + Resources_frank.GoodsReceivedNote_LoadGRN_SuccessMsg + "'); if (document.getElementById('table') != null) {initSorter();sorter.size(20);}",
    OnFailure = "javascript:errormsg()"
};}
<script src="@Url.Content("~/Scripts/js/jquery-1.7.2.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<div class="partialViewCard">
    <div class="partialViewCardHeader">
        <h3>@Resources_frank.GoodsReceivedNote_LoadGRN_NewGRN</h3>
    </div>
    @using (Ajax.BeginForm(null, null, ajaxOpts, new { @class = "form", @id = "frmGRN" }))
    {
        @Html.ValidationSummary(true)
        <br />
        <input type="hidden" id="actionStatus" value="@ViewBag.Response" />
        <input type="hidden" id="statusMsg" value="@ViewBag.msg" />
        <table width="98%" align="center" cellpadding="0">
            <tr>
                <th align="center" width="33.3%">
                    @Resources_frank.Global_String_GRNNo
                </th>
                <th align="center" width="33.3%">
                    @Resources_frank.GoodsReceivedNote_DownloadTemplate_ReceivedDate
                </th>
                <th align="center" width="33.3%">
                    @Resources_frank.Global_String_PONo
                </th>
            </tr>
            <tr>
                <td align="center">
                    @Html.TextBoxFor(m => m.EntityGRN.RefNumber, new { @readonly = "readonly", id = "refNo" })
                </td>
                <td align="center">
                    @Html.EditorFor(m => m.EntityGRN.DeliverDate)
                    @Html.ValidationMessageFor(m => m.EntityGRN.DeliverDate, Resources_frank.Global_String_Required)
                </td>
                <td align="center">
                    @Html.DropDownListFor(x => x.PurchaseOrderId, Model.PurchaseOrders, Resources_frank.Global_String_PleaseSelect, new { id = "POId", onchange = "javascript:GetPOGNDetails(this,'LoadGRN');" })
                    @Html.ValidationMessageFor(x => x.PurchaseOrderId, Resources_frank.Global_String_Required)
                </td>
            </tr>
            <tr>
                <th align="center">
                    @Resources_frank.GoodsReceivedNote_DownloadTemplate_DNNo
                </th>
                <th align="center">
                    @Resources_frank.Global_String_Supplier
                </th>
                <th align="center">
                    @Resources_frank.Global_String_ReceivedBy
                </th>
            </tr>
            <tr>
                <td align="center">
                    @Html.TextBoxFor(m => m.DnNumber, new { id = "dnNumber" })
                    @Html.ValidationMessageFor(m => m.DnNumber, Resources_frank.Global_String_Required)
                </td>
                <td align="center">
                    @ViewBag.SupplierName
                    @Html.HiddenFor(x => x.EntityGRN.SupplierId)
                </td>
                <td align="center">
                    @Html.DropDownListFor(x => x.ReceivedBy, Model.staffs, new { id = "receivedBy" })
                    @Html.ValidationMessageFor(x => x.ReceivedBy, Resources_frank.Global_String_Required)
                </td>
            </tr>
            <tr>
                <th align="center">
                    @Resources_frank.Global_String_Office
                </th>
                <th align="center">
                    @Resources_morgan.Global_String_Warehouse
                </th>
                <th align="center">
                    @Resources_frank.Global_String_DeliveredByName
                </th>
            </tr>
            <tr>
                <td align="center">
                    @Html.DropDownListFor(x => x.CountryOfficeId, Model.SubOffices, Resources_frank.Global_String_PleaseSelect, new { id = "officeId", onchange = "javascript:GetSubofficeWareHouses(this)" })
                    @Html.ValidationMessageFor(x => x.CountryOfficeId, Resources_frank.Global_String_Required)
                </td>
                <td align="center" id="warehouse">
                    @Html.DropDownListFor(x => x.EntityGRN.WareHouseId, Model.Warehouses, Resources_frank.Global_String_PleaseSelect)
                    @Html.ValidationMessageFor(x => x.EntityGRN.WareHouseId, Resources_frank.Global_String_Required)
                </td>
                <td align="center">
                    @Html.TextBoxFor(x => x.DeliveredBy, new { id = "deliveredBy" })
                    @Html.ValidationMessageFor(x => x.DeliveredBy, Resources_frank.Global_String_Required)
                </td>
            </tr>
            <tr>
                <th align="center">
                    @Resources_frank.Global_String_Company
                </th>
                <th align="center">
                    @Resources_frank.GoodsReceivedNote_LoadGRN_VehicleRegNo
                </th>
                <th align="center">
                    @Resources_frank.FleetManager_LoadFleetDetails_DriverLicenseNo
                </th>
            </tr>
            <tr>
                <td align="center">
                    @Html.TextBoxFor(x => x.DeliveryCompany, new { id = "deliveryCompany" })
                    @Html.ValidationMessageFor(x => x.DeliveryCompany, Resources_frank.Global_String_Required)
                </td>
                <td align="center">
                    @Html.TextBoxFor(x => x.VehicleRegNumber, new { id = "vehicleRegNumber" })
                    @Html.ValidationMessageFor(x => x.VehicleRegNumber, Resources_frank.Global_String_Required)
                </td>
                <td align="center">
                    @Html.TextBoxFor(x => x.DriverLicenseNumber, new { id = "driverLicenseNo" })
                    @Html.ValidationMessageFor(x => x.DriverLicenseNumber, Resources_frank.Global_String_Required)
                </td>
            </tr>
            <tr>
                <th align="center">
                    @Resources_frank.GoodsReceivedNote_LoadGRN_ToBeVerifiedBy:
                </th>
                <th align="center">
                </th>
                <th align="center">
                </th>
            </tr>
            <tr>
                <td align="center">
                    @Html.DropDownListFor(x => x.ApproverId, Model.ApproversList, Resources_frank.Global_String_PleaseSelect)
                    @Html.ValidationMessageFor(x => x.ApproverId, Resources_frank.Global_String_Required)
                </td>
                <td align="center">
                </td>
                <td align="center">
                </td>
            </tr>
        </table>
        if (Model.POItemz.Count > 0)
        {
            <h4 style="text-align: center;">
                @Resources_frank.GoodsReceivedNote_DownloadTemplate_ReceivedItems</h4>
            <table width="98%" align="center" cellspacing="0" cellpadding="0" border="1" class="cardTable">
                <tr class="grideven">
                    <th>
                        @Resources_morgan.Global_String_ItemName
                    </th>
                    <th>
                        @Resources_frank.Global_String_QtyOrdered
                    </th>
                    <th>
                        @Resources_frank.GoodsReceivedNote_DownloadTemplate_PreviouslyReceived
                    </th>
                    <th>
                        @Resources_frank.Global_String_UnitsOfMeasure
                    </th>
                    <th>
                        @Resources_frank.Global_String_Package
                    </th>
                       <th>
                        @Resources_frank.GoodsReceivedNote_LoadGRN_NoOfPacks
                    </th>
                    <th>
                        @Resources_frank.Global_String_QtyDelivered
                    </th>
                    <th>
                        @Resources_morgan.Global_String_QtyDamaged
                    </th>
                    <th>
                        @Resources_morgan.Global_String_Comments
                    </th>
                </tr>
                @{string qtyId = "", qtydelvd = "", packId = "";}
                @for (int i = 0; i < Model.POItemz.Count; i++)
                {
                    qtyId = "Qty" + i; qtydelvd = "QtyDelivered" + i; packId = "Id" + i;
                    <tr class="gridodd">
                        <td style="width: 18%;">
                            @Model.POItemz[i].ItemName
                            @Html.HiddenFor(x => x.POItemz[i].POItemId)
                        </td>
                        <td style="width: 10%;">
                            @Model.POItemz[i].QtyOrdered
                            @Html.HiddenFor(m => m.POItemz[i].QtyOrdered, new { id = "qtyordered" })
                        </td>
                        <td style="width: 10%;">
                            @Model.POItemz[i].PreviouslyReceived
                            @Html.HiddenFor(m => m.POItemz[i].PreviouslyReceived, new { id = "qtyprev" })
                        </td>
                        <td style="width: 10%;">
                            @Model.POItemz[i].unitOfMessure
                        </td>
                        <td style="width: 12%;">
                            @Html.DropDownList("Id", new SelectList(Model.POItemz[i].packs, "Id", "Name"), Resources_frank.Global_String_PleaseSelect, new { id = packId, onchange = "javascript:ComputeQty(this, " + i + ")" }) 
                            @Html.ValidationMessage("Id")
                        </td>
                        <td style="width: 15%;">
                            @Html.TextBox("Qty", null, new { @id = qtyId, @class = "ponumericTb", onblur = "javascript:ComputeQtyOnBlur(this, " + i + ")" }) 
                            @*@Html.HiddenFor(m => m.POItemz[i].QtyDelivered, new { id = qtydelvd })*@
                        </td>
                        <td style="width: 10%;">
                            @Html.TextBoxFor(m => m.POItemz[i].QtyDelivered, new { id = qtydelvd, @class = "ponumericTb", @readOnly = "readOnly" })
                            @Html.ValidationMessageFor(m => m.POItemz[i].QtyDelivered, Resources_frank.Global_String_Required)
                        </td>
                        <td style="width: 10%;">
                            @Html.TextBoxFor(m => m.POItemz[i].QtyDamaged, new { id = "QtyDamaged", @class = "ponumericTb" })
                            @Html.ValidationMessageFor(m => m.POItemz[i].QtyDamaged, Resources_frank.Global_String_Required)
                        </td>
                        <td style="width: 15%;">
                            @Html.TextBoxFor(m => m.POItemz[i].comments, new { @class = "comments" })
                            @Html.ValidationMessageFor(m => m.POItemz[i].comments)
                        </td>
                    </tr>
                }
            </table>
            <hr />
            <table width="98%" align="center" cellpadding="0">
                <tr>
                    <td width="100%">
                        <b style="font-weight: bold;">&nbsp;&nbsp;@Resources_morgan.Global_String_Remarks:</b>
                </td>
            </tr>
            <tr>
                <td align="center">
                    @Html.TextAreaFor(x => x.EntityGRN.Remarks)
                    @Html.ValidationMessageFor(x => x.EntityGRN.Remarks)
                </td>
            </tr>
            <tr>
                <td>
                    <br />
                    <input type="submit" class="btn green" value="  @Resources_frank.Global_String_SubmitForVerification  " />
                </td>
            </tr>
        </table>        
               }
    }
    <br />
</div>
